//
//  YYMainTabBarController.m
//  youyuanhuaxia
//
//  Created by tusm on 16/5/27.
//  Copyright © 2016年 CaoJIGen. All rights reserved.
//

#import "YYMainTabBarController.h"
#import "YYMainNavigaationController.h"
#import "YYHomeViewController.h"
#import "YYMineViewController.h"
#import "YYClassifyViewController.h"
#import "YYContactSellerViewController.h"
#import "YYLoginViewController.h"



@interface YYMainTabBarController ()

@end

@implementation YYMainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.view.backgroundColor = [UIColor greenColor];
    
    YYHomeViewController *homeVC = [[YYHomeViewController alloc]init];
//    UINavigationController *navHomeVC = [[UINavigationController alloc] initWithRootViewController:homeVC];
    [self addChildViewController:homeVC imageName:@"tabbar_home" title:@"首页"];
    
    YYClassifyViewController *classVC = [[YYClassifyViewController alloc]init];
//    UINavigationController *navClassVC = [[UINavigationController alloc] initWithRootViewController:classVC];
    [self addChildViewController:classVC imageName:@"tabbar_discover" title:@"分类"];
    
    YYContactSellerViewController *sellVC = [[YYContactSellerViewController alloc]init];
//    UINavigationController *navSellVC = [[UINavigationController alloc] initWithRootViewController:sellVC];
    [self addChildViewController:sellVC imageName:@"tabbar_message_center" title:@"联系卖家"];
    
//    YYMineViewController *mineVC = [[YYMineViewController alloc]init];
    YYLoginViewController *mineVC = [[YYLoginViewController alloc]init]; //测试登陆用
//    UINavigationController *navMineVC = [[UINavigationController alloc] initWithRootViewController:mineVC];
    
    [self addChildViewController:mineVC imageName:@"tabbar_profile" title:@"我"];

    
}

//添加子控制器  图片和名字
- (void)addChildViewController:(UIViewController *)childCtrl imageName:(NSString *)imageName title:(NSString *)title{
    
    
    //设置选中与未选中的图片-->指定一下渲染模式-->图片以原样的方式显示出来
    childCtrl.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childCtrl.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //设置标题
    childCtrl.tabBarItem.title = title;
//    [childCtrl.navigationItem setTitle:title];
    //    childCtrl.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    //指定一下属性
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    dic[NSForegroundColorAttributeName] = [UIColor orangeColor];
    //指定字体
    dic[NSFontAttributeName] = [UIFont systemFontOfSize:18];
    
    
    //指定选中状态下文字颜色
    [childCtrl.tabBarItem setTitleTextAttributes:dic forState:UIControlStateSelected];
    
    [self addChildViewController:childCtrl];
}

@end
